#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H

#include <QtCore/QHash>
#include <QtGui/QMainWindow>

static const QString FILE_MENU = "FIL_MENU";
static const QString EDIT_MENU = "EDI_MENU";
static const QString VIEW_MENU = "VIE_MENU";
static const QString TOOLS_MENU = "TOO_MENU";
static const QString HELP_MENU = "HEL_MENU";
static const QString FINISHED = "FINISHED";

class EditorArea;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    static MainWindow* getInstance();
    static void destroy();

    QMenu* getMenu(const QString& menuId) const;
    QToolBar* getToolBar(const QString& toolBarId) const;

    void putToBag(const QString& key, const QVariant& value);
    QVariant bagValue(const QString& key) const;

protected:
    void closeEvent(QCloseEvent* event);

private:
    MainWindow();
    ~MainWindow();

    void init();

    void addMenus();
    void addToolBars();
    void createActions();
    void createMenus();
    void createToolbars();
    void createStatusBar();
    void createPerspectives();

    void connectSlots();

    void readSettings();
    void readPerspectiveSettings();
    void writeSettings();
    void writeSession();

private:
    QHash<QString, QVariant> m_bag;
    QHash<QString, QMenu* > m_menus;
    QHash<QString, QToolBar* > m_toolBars;

    EditorArea* m_editorArea;

    QMenu* m_fileMenu;
    QMenu* m_editMenu;
    QMenu* m_viewMenu;
    QMenu* m_toolsMenu;
    QMenu* m_helpMenu;

    QToolBar* m_undoToolbar;

    // Undo toolbar
    QAction* m_undoAction;
    QAction* m_redoAction;

    // Edit menu
    QAction* m_undoMenuAction;
    QAction* m_redoMenuAction;

    // Tools menu
    QAction* m_restoreSessionMenuAction;
    QAction* m_optionsMenuAction;

    // Help menu
    QAction* m_aboutMenuAction;
};

#endif

